package org.example.service.Impl;

import org.example.config.R;
import org.example.domain.Post;
import org.example.mapper.PostMapper;
import org.example.service.PostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class PostServiceImpl implements PostService {
    @Autowired
    PostMapper postMapper;
    @Override
    public List<Post> postList(Post post) {
        return postMapper.postList(post);
    }

    @Override
    public R save(Post post) {
        post.setUpdateTime(new Date());
        postMapper.save(post);
        return R.successed(null);
    }

    @Override
    public R delById(Integer id) {
        postMapper.delById(id);
        return R.successed(null);
    }

    @Override
    public R updateById(Post post) {
        post.setUpdateTime(new Date());
        postMapper.updateById(post);
        return R.successed(null);
    }

    @Override
    public List<Post> list() {
        return postMapper.list();
    }


}
